tests: Check that example symbol isn't released
authorMatthew Leeds <matthew.leeds@endlessm.com>
Wed, 17 Jun 2020 21:35:18 +0000 (14:35 -0700)
committerMatthew Leeds <matthew.leeds@endlessm.com>
Wed, 17 Jun 2020 22:28:15 +0000 (15:28 -0700)
For the motivation for this see #2132.

tests/kolainst/libtest-core.sh
tests/test-symbols.sh

index 945d2857240eb1ef21125c0294cee5d42ef5090c..64b3e0a30e0ea2de30faf6833f76ca20c6d48855 100644 (file)
@@ -115,6 +115,16 @@ assert_file_has_content () {
     done
 }
 
+assert_file_has_content_once () {
+    fpath=$1
+    shift
+    for re in "$@"; do
+        if ! test $(grep -e "$re" "$fpath" | wc -l) = "1"; then
+            _fatal_print_file "$fpath" "File '$fpath' doesn't match regexp '$re' exactly once"
+        fi
+    done
+}
+
 assert_file_has_content_literal () {
     fpath=$1; shift
     for s in "$@"; do
index f6742d93ce30f1e3838745289592e4616dc3e845..8f67a46c4a06f0b54fd28cd5c74478aa7ef3078c 100755 (executable)
@@ -21,6 +21,8 @@
 
 set -xeuo pipefail
 
+. $(dirname $0)/libtest.sh
+
 echo '1..3'
 
 released_syms=${G_TEST_SRCDIR}/src/libostree/libostree-released.sym
@@ -41,6 +43,16 @@ echo "Verifying all expected symbols are actually exported..."
 grep --no-filename ' ostree_[A-Za-z0-9_]*;' ${released_syms} ${devel_syms} ${experimental_sym} | sed -e 's,^ *\([A-Za-z0-9_]*\);,\1,' | sort -u > expected-symbols.txt
 eu-readelf -a ${G_TEST_BUILDDIR}/.libs/libostree-1.so | grep 'FUNC.*GLOBAL.*DEFAULT.*@@LIBOSTREE_' | sed -e 's,^.* \(ostree_[A-Za-z0-9_]*\)@@LIBOSTREE_[0-9A-Z_.]*,\1,' |sort -u > found-symbols.txt
 diff -u expected-symbols.txt found-symbols.txt
+
+echo "Checking that the example symbol wasn't copy-pasted..."
+if test -f ${devel_syms}; then
+  assert_file_has_content_once ${devel_syms} "someostree_symbol_deleteme"
+fi
+if test -f ${experimental_sym}; then
+  assert_not_file_has_content ${experimental_sym} "someostree_symbol_deleteme"
+fi
+assert_not_file_has_content ${released_syms} "someostree_symbol_deleteme"
+
 echo "ok exports"
 
 # cmd__private__ is private.  The fetcher symbol should not have been made public.